<%= header %>
<%= boomerangScript %>
<base href="/pages/08-ember/17-wait.html" />

<script src="../../vendor/jquery/dist/jquery.min.js"></script>
<script src="../../vendor/ember/ember.prod.js"></script>
<script src="../../vendor/handlebars/handlebars.min.js"></script>
<script src="../../vendor/ember/ember-template-compiler.js"></script>
<script>
window.imgs = [-1];

window.html5_mode = true;

//
// Routes:
// 1. Home page (hard nav) - Filter: n/a, (hard navs can't be filtered, doesn't wait)
// 2. Home page (soft nav) - Filter: true, takes: 5 seconds (fires after resource)
// 3. Home page (soft nav) - Filter: true, takes: 1 ms (fires before resource)
// 4. Home page (soft nav) - Filter: false (doesn't wait)
//
window.ember_nav_routes = ["/widgets/1", "/widgets/2", ""];

// how long we should wait for each route
var routeWaits = [
	// spa_hard isn't filtered
	5000,
	1,
	0
];

// we'll put the end timestamps of each route in here so we can validate against beacons
window.spaWaitCompleteTimes = [];

// current route number
var routeNumber = 0;

// callback for each route
window.ember_route_wait = function() {
	if (routeWaits[routeNumber]) {
		setTimeout(function() {
			window.spaWaitCompleteTimes.push(BOOMR.now());

			// call complete 5 seconds afterward route start
			BOOMR.plugins.SPA.wait_complete();
		}, routeWaits[routeNumber]);

		routeNumber++;

		return true;
	}
	else {
		// not waiting for this route
		return false;
	}
};
</script>
<script src="support/app.js"></script>

<!-- Handlebars templates for our application. -->
<script type="text/x-handlebars">
	<div class="container">
		{{outlet}}
	</div>
</script>

<script src="/test-templates/spa/17-wait.js" type="text/javascript"></script>
<script src="17-wait.js"></script>
<script>
BOOMR_test.init({
	testAfterOnBeacon: BOOMR.plugins.AutoXHR ? 4 : 1,
	History: {
		enabled: true,
		monitorHistory: false
	},
	instrument_xhr: true,
	autorun: false
});
</script>

<%= footer %>
